package mortgage;

import java.sql.PreparedStatement;

import connection.MyConnection;

public class Mortgage_Edit {
	
	private int id;
	private String name;
	private String item;
	private double  weight;
	private double  purity;
	private double  givenamount;
	private double  rateofinterest;
	private double  interest;
	private String sendto;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public double getWeight() {
		return weight;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
	public double getPurity() {
		return purity;
	}
	public void setPurity(double purity) {
		this.purity = purity;
	}
	public double getGivenamount() {
		return givenamount;
	}
	public void setGivenamount(double givenamount) {
		this.givenamount = givenamount;
	}
	public double getRateofinterest() {
		return rateofinterest;
	}
	public void setRateofinterest(double rateofinterest) {
		this.rateofinterest = rateofinterest;
	}
	public double getInterest() {
		return interest;
	}
	public void setInterest(double interest) {
		this.interest = interest;
	}
	public String getSendto() {
		return sendto;
	}
	public void setSendto(String sendto) {
		this.sendto = sendto;
	}
	
	public String execute() throws  Exception
	{
		MyConnection mc = new MyConnection();
		mc.connect();
		
		try
		{
			PreparedStatement ps = mc.con.prepareStatement("update mortgageentry set name=?, item=?, weight=?, purity=?, givenamount=?, rateofinterest=?, interest=?, sendto=? where id = '"+id+"' ");
			ps.setString(1, name);
			ps.setString(2, item);
			ps.setDouble(3, weight);
			ps.setDouble(4, purity);
			ps.setDouble(5, givenamount);
			ps.setDouble(6, rateofinterest);
			ps.setDouble(7, interest);
			ps.setString(8, sendto);
			ps.executeUpdate();
		}
		
		catch (Exception e) {
			e.printStackTrace();
		}
		return "success";
	}
}
